import React from 'react';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import './style.less';

interface IProps {
  name: string; // 定义动画名
  time?: number; // 动画时长
  enterTime?: number;
  leaveTime?: number;
}

/**
 * 组件进出动画
 */
const Transition: React.SFC<IProps> = ({ name, time = 400, enterTime, leaveTime, children }) => (
  <ReactCSSTransitionGroup transitionName={name} transitionEnterTimeout={enterTime || time} transitionLeaveTimeout={leaveTime || time}>
    {children}
  </ReactCSSTransitionGroup>
);

export default Transition;
